package com.yannan.lock.core.util;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;


public class IphoneUtil {
	
	/*@Value("${importXml.url}")
    private String importXmlUrl = "";*/
	

	
	public static int sendsmss(String iphone) {
		String Url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
		HttpClient client = new HttpClient();
		PostMethod method = new PostMethod(Url);

		//client.getParams().setContentCharset("GBK");
		client.getParams().setContentCharset("UTF-8");
		method.setRequestHeader("ContentType","application/x-www-form-urlencoded;charset=UTF-8");

		int mobile_code = (int)((Math.random()*9+1)*100000);

		//System.out.println(mobile);

	    String content = new String("重置密码验证码是：" + mobile_code + "。请您在30分钟内填写。如非本人操作，请忽略本短信。");

		NameValuePair[] data = {//提交短信
			    new NameValuePair("account", "cf_bjynkj"),
			    new NameValuePair("password", "Yannan2016"), //密码可以使用明文密码或使用32位MD5加密
			    //new NameValuePair("password", util.StringUtil.MD5Encode("密码")),
			    new NameValuePair("mobile", iphone),
			    new NameValuePair("content", content),
		};

		method.setRequestBody(data);

		try {
			client.executeMethod(method);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mobile_code;

	}
	
}
